{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from gs_quant.common import PayReceive, Currency\n",
    "from gs_quant.instrument import IRSwap\n",
    "from gs_quant.session import Environment, GsSession\n",
    "from gs_quant.risk import DollarPrice, IRDelta\n",
    "from gs_quant.common import AggregationLevel\n",
    "from gs_quant.markets import HistoricalPricingContext\n",
    "from datetime import date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# external users should substitute their client id and secret\n",
    "GsSession.use(Environment.PROD, client_id=None, client_secret=None, scopes=('run_analytics',))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "swap_10bps = IRSwap(PayReceive.Receive, '5y', Currency.EUR, fixed_rate='atm+10')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "Contexts - HistoricalPricingContext",
     "Metrics - aggregation_level"
    ]
   },
   "outputs": [],
   "source": [
    "with HistoricalPricingContext(date(2020, 3, 2), date(2020, 4, 1), show_progress=True):\n",
    "    res_f = swap_10bps.calc((DollarPrice, IRDelta, IRDelta(aggregation_level=AggregationLevel.Type, currency='local')))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(res_f.result())  # retrieve all results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "Results - historical results"
    ]
   },
   "outputs": [],
   "source": [
    "print(res_f[DollarPrice])  # retrieve historical prices"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "metadata": {
     "collapsed": false
    },
    "source": []
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
